home *** CD-ROM | disk | FTP | other *** search
/ Zoom 2 / Zoom - Release 2 (1996)(Active Software)[!].iso / texts / amoszine / arts / az_code_clinic.asc < prev    next >
Text File  |  1992-09-02  |  8KB  |  187 lines

  1. @1
  2.                             C O D E   C l i n i c
  3. @3                      Is the Game, Lee Bambers the Name
  4.                       ---------------------------------
  5. @1
  6. CC> What's the prob, dude?
  7. @4
  8. PP> When using the Dual Playfield it keeps distorting the background screen.
  9.     I used it like this:
  10.  
  11.        Load Iff "[a 960X200,8 colour screen] into Screen 0
  12.        Load Iff "[a 320X200,8 colour screen] into Screen 1
  13.        Dual Playfield 0,1
  14. @3
  15. AA> I know where of you speak.  I had similar problems with my AMOSEyes when
  16.     I wanted a backdrop for my Instruction Manual Reader.   I just blamed it
  17.     on AMOS and did something else, but upon reflection, it should not have
  18.     happened, and I wanted by backdrop, so I got it sorted.
  19.  
  20.     The answer to your pain lies in the time it takes AMOS to load in an IFF
  21.     picture and the time it takes to settup a dual playfield screen.   Or so
  22.     I hypothosised.  In fact, I tried every smegging command under  the  sun
  23.     until I used WAIT VBL  between  the  last  Load Iff  and  Dual Playfield
  24.     command.
  25.  
  26.     Your code should read:
  27.  
  28.        Load Iff "[bla bla bla]",0
  29.        Load Iff "[whatever...]",1
  30.        Wait Vbl
  31.        Dual Playfield 0,1
  32.  
  33.     I true AZ style, I did more than just propose  a  possible  solution,  I
  34.     went into AMOS and tried out your code.  Something that isn't  mentioned
  35.     in the AMOS manual is that when you are creating dual playfield  screens
  36.     of larger sizes, both screen need to match and/or exceed the size of the
  37.     screen.  Your 320 wide screen didn't and  the  dual  playfield  probably
  38.     ignored the actual size in order to create a screen which would  fill  a
  39.     complete a single raster line.  In short, you need your second screen to
  40.     be at least 352 pixels wide.  That's two words bigger than your standard
  41.     size screen.  Incidently, this is the size you'd  find  most  commercial
  42.     games using. Think about it, do you see borders in your typical 'bigboy'
  43.     game? Nope.
  44.  
  45.     Because I'm such a nice guy, I've included an AMOS program  which  shows
  46.     you what I'm slavering about.  I'd come round your house  and  hit  your
  47.     computer with my rubber wrist rest if I thought it  could  help  but  my
  48.     mother won't give me the key.  So heed my advice and play nicely. 
  49. @1
  50. CC> Righty, onto our next troubled sole, what's up?
  51. @4
  52. PP> I have a coding problem.  You have two objects each have there own x & y
  53.     variables.  I want to have a procedure that will take in the 4 variables
  54.     x1,y1 & x2,y2 of the two objects, and return an angle that will face the
  55.     first object in the direction of the second object,i.e A lock on missile
  56.     after a ship.
  57.  
  58.     The return value should be from 0 to 359.
  59.  
  60.     Now for the annoying bit, the routine can't use any floating point maths
  61.     so careful thought is needed.
  62. @3
  63. AA> I'm afraid this one is a toughy.  If you can't use floating point number
  64.     systems, you can rule out the use of the Amos commands that will do this
  65.     in an instant.  I can only assume your neurotic  about  saving  variable
  66.     space or ultimately going to write it in m/c.  The case of using integer
  67.     numbers for homing routines has turned up before in my own creations.  I
  68.     had no half-way method of doing something, I end up  binding  everything
  69.     into a single routine.  So the homing routine would not need an angle of
  70.     0-359 degrees, it would automatically assign x/y  increments  at  points
  71.     along the cycle.  This is the  natural  alternative  to  floating  point
  72.     homing routines.
  73.  
  74.     Lets say you had this line, using floating point maths:
  75.  
  76.     SHIPX@3#@3=SHIPX@3#@3+0.5
  77.  
  78.     In 10 cycles, it would have travelled 5 pixels along the X axis.   Using
  79.     point integer increments, the code would read:
  80.  
  81.     If SHIPXCOUNT=2
  82.        SHIPXCOUNT=0
  83.        SHIPX=SHIPX+1
  84.     End If
  85.     SHIPXCOUNT=SHIPXCOUNT+1
  86.  
  87.     This would convert easily to machine code, assuming some settings, as:
  88.  
  89.            CMP    @3#@32,SHIPXCOUNT(a0)
  90.            BNE JUMP1
  91.            MOVE.W @3#@30,SHIPXCOUNT(a0)
  92.            ADD.W  @3#@31,SHIPX(a0)
  93.     JUMP1: ADD.W  @3#@31,SHIPXCOUNT(a0)
  94.  
  95.     Now if you can grasp that, the next step is to generate  the  number  to
  96.     compare with the shipcount.  This  number  will  be  created  using  the
  97.     distance between the two objects.   I've included the source code to the
  98.     above example.    Generating the point number is another story entirely.
  99.  
  100.     But trying to obtain angles without FP numbers is  like  trying  to  eat
  101.     without fingers.  If anyone can prove me wrong, please try.  For now, it
  102.     would seem you have a simple choice.
  103.  
  104.     a) Change the idea enough to allow a different approach to the code, or
  105.     b) Sit down, and work out your own angles:
  106.  
  107.     I say this for the very reason I'm a programmer.  I would say it is very
  108.     possible to create your own system where the distance  can  be  given  a
  109.     finite defenision within a circle from a base object,  and this then can
  110.     be used to approximate an angle.
  111.  
  112.     A quick (and crude) example, is:
  113.  
  114.     Procedure LOCK[x1,y1,x2,y2]
  115.      '
  116.      If X1<X2
  117.         If Y1<Y2
  118.            ANGLE=315
  119.         Else
  120.            ANGLE=225
  121.         @3Endif
  122.      Else
  123.         If Y1<Y2
  124.            ANGLE=45
  125.         Else
  126.            ANGLE=135
  127.         End If
  128.      End If
  129.      '
  130.     End Proc
  131.  
  132.     Not the answer you might have wanted, but it was a toughy!   Let me know
  133.     what you decide!
  134. @1
  135. CC> You there, need any help?
  136. @4
  137. PP> How do you simulate the hands on a clock, at the correct angle?
  138. @3
  139. AA> Easy.  Read the maths chapter of the Amos manual about SIN & COS.  Now
  140.     look up the junior book for telling the time.  When you have the number
  141.     of figures on a clock, find out how many minutes in an hour.  Yes, it's
  142.     very easy.  Whether you want a simple clock or a commercial quality
  143.     clock is two different considerations.  For the sake of time and space,
  144.     I'll give you the simple version:
  145.  
  146.     Basically, a circle has 360 points around it.  0 and 360 are the same
  147.     point and the points are consecutive around the circumference.  So 180
  148.     would be half way round, 350 would be nearly all the way round, etc.
  149.  
  150.     Their are 60 seconds in a minute and the SECONDS HAND on a clock will
  151.     go round inside this 60 seconds.  So for every second, the SECONDS
  152.     HAND will need to move in steps until the sixtyth move will have moved
  153.     the hand back onto the 0/360'th point.  How many points must be jumped
  154.     to get 360 points covered in 60 steps?
  155.  
  156.        360 / 60 = 6  so thats 6 pixels
  157.  
  158.     This method of deduction must be applied to the hours hand which only
  159.     completes a circle in (60*60*12) seconds.
  160. @3
  161.     The CC-Solution-3 program showns you how this can be achieved.  It's a
  162.     simple routine, with many points worth improving.  The most important
  163.     factors for improvement are graphics and size.  A smaller clock is
  164.     vital if you want it fast.  Graphics would have to include the hands.
  165.     Anything other than lines will have to be considered for drawing.  This
  166.     may not be practical with 360 possibilities!
  167.  
  168.  
  169. @3CC> Well, I'm done here.  Any other problems can be sent to my address below
  170.     and I'll answer them in these pages.  Bye!
  171.  
  172. @1
  173.     ADDRESS:   Lee Bamber,
  174.                Dept. AZCC.
  175.                'Rockville',
  176.                Warrington Road,
  177.                Lower Ince,
  178.                Wigan,
  179.                Lancashire,
  180.                WN3 4QG.
  181.  
  182. @4
  183.      As per usual, any correspondance will be replied to and I'll even put
  184.      in one of my prized Info Sheets!  Now how's that for nicey-ness-ness?
  185. @1
  186.      End.
  187.